package com.aidong.myprofile.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aidong.login.dao.MemberInformationDao;
import com.aidong.myprofile.biz.MyPersonalMsgBiz;
import com.aidong.myprofile.dao.MyPersonalMsgDao;
import com.aidong.myprofile.entity.HailFellowMsg;
import com.aidong.myprofile.entity.MyPersonalMsg;
import com.aidong.util.ImageUpload;
import com.aidong.util.QiniuUtil;

@Service("personalMsgBiz")
public class MyPersonalMsgBizImpl implements MyPersonalMsgBiz {
	
	private MyPersonalMsgDao personalMsgDao;
	
	private MemberInformationDao memberInformationDao;
	
	@Autowired
	public void setMemberInformationDao(MemberInformationDao memberInformationDao) {
		this.memberInformationDao = memberInformationDao;
	}

	@Autowired
	public void setPersonalMsgDao(MyPersonalMsgDao personalMsgDao) {
		this.personalMsgDao = personalMsgDao;
	}

	/**
	 * 获得个人信息
	 * @param idongId
	 * @return
	 */
	@Override
	public MyPersonalMsg getPersonalMsg(String idongId) {
		MyPersonalMsg peresonals = personalMsgDao.getPersonalMsg(idongId);
		/*Map<String, Object> paraMap = new HashMap<String, Object>();
		paraMap.put("idongId", idongId);
		memberInformationDao.addMemberPopty(paraMap);*/
		if(peresonals != null){
			peresonals.setTwoDimensionalCode(QiniuUtil.TOWPREIX + peresonals.getIdongId());
			if(2 == peresonals.getLoginType()){ // QQ
				peresonals.setThirdNickName("QQ：" + peresonals.getNickName());
			}else if(3 == peresonals.getLoginType()){ // 微信
				peresonals.setThirdNickName("微信：" + peresonals.getNickName());
			}else if(4 == peresonals.getLoginType()){ // 微博
				peresonals.setThirdNickName("微博：" + peresonals.getNickName());
			}
		}
			
		return peresonals;
	}

	/**
	 * 消息未读条数
	 * @param idongId
	 * @return
	 */
	@Override
	public Map<String, Object> getMessageUnreadCount(int idongId) {
		return personalMsgDao.getMessageUnreadCount(idongId);
	}

	/**
	 * 我关注的人数
	 * @param idongId
	 * @return
	 */
	@Override
	public int getMyAttentionCount(int idongId) {
		return personalMsgDao.getMyAttentionCount(idongId);
	}

	/**
	 * 我的粉丝人数
	 * @param idongId
	 * @return
	 */
	@Override
	public int getMyFansCount(int idongId) {
		return personalMsgDao.getMyFansCount(idongId);
	}

	/**
	 * 修改个人信息
	 * @param map
	 */
	@Override
	public void editMyPersonMsg(MyPersonalMsg personalMsg) {
		String headUrl = personalMsg.getHeadUrl(); // 头像
		if(!"".equals(headUrl) && headUrl != null){
			String datePath = ImageUpload.readBlob(headUrl, "portrait");
			personalMsg.setHeadUrl(datePath);
		}
		personalMsgDao.editMyPersonMsg(personalMsg);
	}

	/**
	 * 查看好友资料
	 * @param idongId
	 * @return
	 */
	@Override
	public HailFellowMsg getHailFellowMsg(int idongId) {
		// 增加热度值
//		memberInformationDao.addMemberPopty(idongId);
		return personalMsgDao.getHailFellowMsg(idongId);
	}

	/**
	 * 预约条数
	 * @param idongId
	 * @return
	 */
	@Override
	public Map<String, Object> getAppointmentCount(int idongId) {
		return personalMsgDao.getAppointmentCount(idongId);
	}

	@Override
	public void bindQq(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.bindQq(map);
	}

	@Override
	public void bindWeiBo(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.bindWeiBo(map);
	}

	@Override
	public void bindWeChat(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.bindWeChat(map);
	}

	@Override
	public void unBindQq(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.unBindQq(map);
	}

	@Override
	public void unBindWeiBo(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.unBindWeiBo(map);
	}

	@Override
	public void unBindWeChat(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.unBindWeChat(map);
	}

	@Override
	public List<Map<String, Object>> qqAccount(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return personalMsgDao.qqAccount(map);
	}

	@Override
	public List<Map<String, Object>> weiBoAccount(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return personalMsgDao.weiBoAccount(map);
	}

	@Override
	public List<Map<String, Object>> weChatAccount(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return personalMsgDao.weChatAccount(map);
	}

	@Override
	public int selectDynamicCount(int idongId) {
		// TODO Auto-generated method stub
		return personalMsgDao.selectDynamicCount(idongId);
	}

	@Override
	public int selectMessageCount(int idongId) {
		// TODO Auto-generated method stub
		return personalMsgDao.selectMessageCount(idongId);
	}

	@Override
	public void deleteMessageNoPhone(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.deleteMessageNoPhone(map);
	}

	@Override
	public void deleteDynamicNoPhone(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.deleteDynamicNoPhone(map);
	}

	@Override
	public void deleteMemberNoPhone(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.deleteMemberNoPhone(map);
	}

	@Override
	public void bindQq2(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.bindQq2(map);
	}

	@Override
	public void bindWeiBo2(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.bindWeiBo2(map);
	}

	@Override
	public void bindWeChat2(Map<String, Object> map) {
		// TODO Auto-generated method stub
		personalMsgDao.bindWeChat2(map);
	}

	@Override
	public Map<String, Object> selectTaskTags(int idongId) {
		// TODO Auto-generated method stub
		return personalMsgDao.selectTaskTags(idongId);
	}
	
	
	
	/**
	 * 根据爱动号查询出已支付未删除的营养品，餐饮，装备，赛事总数
	 * @param map
	 * @return
	 */
	public Integer selectMyOrderCou(Map<String, Object> map){
		return personalMsgDao.selectMyOrderCou(map);
	}
	/**
	 * 根据爱动号查出预约的课程，场馆，活动，私教数量
	 * @param map
	 * @return
	 */
	@Override
	public Integer selectMySubBan(Map<String, Object> map) {
		return personalMsgDao.selectMySubBan(map);
	}

	@Override
	public Integer selectMySubCoach(Map<String, Object> map) {
		return personalMsgDao.selectMySubCoach(map);
	}

	@Override
	public Integer selectMySubCam(Map<String, Object> map) {
		return personalMsgDao.selectMySubCam(map);
	}

	@Override
	public Integer selectMySubAct(Map<String, Object> map) {
		return personalMsgDao.selectMySubAct(map);
	}
}
